<template>
  <el-dialog
    :ref="dialogRef"
    :title="title"
    :visible.sync="visible"
    :width="width"
    :before-close="handleClose"
    v-bind="$attrs"
    v-on="$listeners"
  >
    <slot></slot>
    <span v-if="showFooter" slot="footer" class="dialog-footer">
      <el-button size="small" @click="handleClose">取 消</el-button>
      <el-button size="small" type="primary" @click="dialogVisible = false"
        >确 定</el-button
      >
    </span>
  </el-dialog>
</template>

<script>
export default {
  props: {
    dialogRef: {
      type: String,
      default: "dialogRef",
    },
    visible: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String,
      default: "弹窗",
    },
    width: {
      type: String,
      default: "30%",
    },
    showFooter: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {};
  },
  computed: {},
  methods: {
    handleClose() {
      // console.log(this.$listeners);
      this.$emit("update:visible", false);
      this.$emit("close");
    },
  },
};
</script>

<style lang="scss" scoped>
.el-dialog__wrapper {
  display: flex;
  align-items: center;
  ::v-deep .el-dialog {
    margin-top: 0 !important;
  }
}
</style>
